package cn.kent.controller;

import cn.kent.config.RabbitConfig;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
public class HelloController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("hello")
    public void hello() {
        // 正常发送 - 消息正常到达交换机
        rabbitTemplate.convertAndSend(RabbitConfig.MSG_EXCHANGE_NAME, RabbitConfig.MSG_QUEUE_NAME, "你好，鹏鹏！", new CorrelationData(UUID.randomUUID().toString()));
//        // 消息未到达交换机
//        rabbitTemplate.convertAndSend(RabbitConfig.MSG_EXCHANGE_NAME, RabbitConfig.MSG_QUEUE_NAME, "你好，鹏鹏！", new CorrelationData(UUID.randomUUID().toString()));
//        // 消息未到达队列
//        rabbitTemplate.convertAndSend(RabbitConfig.MSG_EXCHANGE_NAME, "RabbitConfig.MSG_QUEUE_NAME", "你好，鹏鹏！", new CorrelationData(UUID.randomUUID().toString()));

    }
}
